/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.restaurant.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;

/**
 *
 * @author Dexter
 */
@Entity
@Table(name = "ProductTypes")
@NamedQueries({
    @NamedQuery(name = "ProductTypes.findAll", query = "SELECT p FROM ProductTypes p"),
    @NamedQuery(name = "ProductTypes.findByProductTypeId", query = "SELECT p FROM ProductTypes p WHERE p.productTypeId = :productTypeId"),
    @NamedQuery(name = "ProductTypes.findByName", query = "SELECT p FROM ProductTypes p WHERE p.name = :name")})
public class ProductTypes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ProductTypeId")
    private Long productTypeId;
    @Size(max = 100)
    @Column(name = "Name")
    private String name;
    @OneToMany(mappedBy = "productTypeId", fetch = FetchType.LAZY)
    private List<Products> productsList;

    public ProductTypes() {
    }

    public ProductTypes(Long productTypeId) {
        this.productTypeId = productTypeId;
    }

    public Long getProductTypeId() {
        return productTypeId;
    }

    public void setProductTypeId(Long productTypeId) {
        this.productTypeId = productTypeId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Products> getProductsList() {
        return productsList;
    }

    public void setProductsList(List<Products> productsList) {
        this.productsList = productsList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (productTypeId != null ? productTypeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ProductTypes)) {
            return false;
        }
        ProductTypes other = (ProductTypes) object;
        if ((this.productTypeId == null && other.productTypeId != null) || (this.productTypeId != null && !this.productTypeId.equals(other.productTypeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return name;
    }
    
}
